<?php
session_start();
if(empty($_SESSION['user'])){
	echo '<script>alert("请先登录");window.location.href="/home/login.php";</script>';
}
$post = $_POST;
if(isset($post['comment']) && !empty(!$post['comment'])){
	echo '<script>alert("评论不能为空");window.location.href=history.go(-1);</script>';
}
$post['ctime'] = time();
$post['uid'] = $_SESSION['user']['id'];
$config = include('../public/config/config.php');
include('../public/func/db.php');
$res = insert($config,'comment',$post);
if($res == ''){
	echo '<script>alert("评论成功");window.location.href="/home/articledetail.php?id='.$post['aid'].'";</script>';
}else{
	echo '<script>alert("评论失败");window.location.href=history.go(-1);</script>';
}
